<?php

/**
 * This is the model class for table "stuperformance".
 *
 * The followings are the available columns in table 'stuperformance':
 * @property integer $stuPerformanceId
 * @property integer $uId
 * @property double $term_1
 * @property double $term_2
 * @property double $term_3
 * @property double $term_4
 * @property double $term_5
 * @property double $term_6
 * @property double $term_7
 * @property double $term_8
 *
 * The followings are the available model relations:
 * @property User $u
 */
class Stuperformance extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Stuperformance the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'stuperformance';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('uId', 'required'),
			array('uId', 'numerical', 'integerOnly'=>true),
			array('term_1, term_2, term_3, term_4, term_5, term_6, term_7, term_8', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('stuPerformanceId, uId, term_1, term_2, term_3, term_4, term_5, term_6, term_7, term_8', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'u' => array(self::BELONGS_TO, 'User', 'uId'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'stuPerformanceId' => 'Stu Performance',
			'uId' => 'U',
			'term_1' => 'Term 1',
			'term_2' => 'Term 2',
			'term_3' => 'Term 3',
			'term_4' => 'Term 4',
			'term_5' => 'Term 5',
			'term_6' => 'Term 6',
			'term_7' => 'Term 7',
			'term_8' => 'Term 8',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('stuPerformanceId',$this->stuPerformanceId);
		$criteria->compare('uId',$this->uId);
		$criteria->compare('term_1',$this->term_1);
		$criteria->compare('term_2',$this->term_2);
		$criteria->compare('term_3',$this->term_3);
		$criteria->compare('term_4',$this->term_4);
		$criteria->compare('term_5',$this->term_5);
		$criteria->compare('term_6',$this->term_6);
		$criteria->compare('term_7',$this->term_7);
		$criteria->compare('term_8',$this->term_8);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}